package com.ourcraft.informationcollectionsystem.utils.authority;

/**
 * 权限管理时，各模块权限的权限码
 *
 * @author Z0136
 * @since 2023/10/31
 */
public enum AuthorityCode {
    //    QianYi
    RECORD_SUBMIT(1),
    DATA_FORM_SUBMIT(2),
    //    AmeYukari
    RECORD_EXAMINE(3),
    DATA_FORM_EXAMINE(4),
    //    Z0136
    USER_MANAGE(5),
    ROLE_MANAGE(6),
    INVESTIGATION_MANAGE(7),
    //    JoshMiao
    DATA_VISUALIZATION(8),
    //    SceneryMC
    FILLING_INFO_QUERY(9),
    DATA_FORM_QUERY(10),
    DATA_ALTER(11),
    //    Lys
    SEND_MESSAGE(12),
    DATA_EXPORT(13);


    private Integer code; // 权限码

    AuthorityCode(Integer code) {
        this.code = code;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Boolean validate(Integer authority) {
        return (authority >> this.code & 1) == 1;
    }
}
